﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using WebApplication3.Models;

namespace WebApplication3.Controllers
{
    public class DefaultController : Controller
    {
        // GET: Default
        public ActionResult Index()
        {
            var context = new SchoolEntities();
            var result = context.Person.ToList();
            return View(result);
        }
        public ActionResult Detail(int id)
        {
            var context = new SchoolEntities();
            var person = context.Person.Find(id);
            return View(person);
        }
        public ActionResult Delete(int id)
        {
            var context = new SchoolEntities();
            var person = context.Person.Find(id);
            context.Person.Remove(person);
            context.SaveChanges();
            return RedirectToAction("Index");
        }
    }
}